Ext.define('BISC.view.CtxMnuFilter', {
    extend: 'Ext.menu.Menu',
    scope: this,
    listeners: {
        click: function( menu, item ) {
            switch( item.identifier ) {
                case 'update':
                    this.update();
                    break;
                case 'delete':
                    Ext.Msg.confirm('Remove Filter', 'Are you sure you want remove "' + this.record.data.name + '"?', function( btn, nothing, item ) {
                        if ( btn == 'yes' ) {
                            this.remove();
                        }
                    }, this);
                    break;
            }
        }
    },
    initComponent: function() {
        var me = this;

        Ext.applyIf(me, {
            items: [
                {
                    text: 'Edit',
                    iconCls: 'icon_editFilter',
                    identifier: 'update'
                },
                {
                    text: 'Remove',
                    iconCls: 'icon_removeFilter',
                    identifier: 'delete'
                }
            ]
        });
        me.callParent(arguments);
    },
    remove: function() {
        Ext.Ajax.request({
            url: 'http://localhost:8888/removeFilter?filterId=' + this.record.data.filterId,
            success: function() { Ext.getCmp('filtersGrid').getStore().load() }
        });
    },
    update: function() {
        Ext.create('Ext.window.Window', {
            title: 'Edit Filter ' + this.record.data.name,
            iconCls: 'icon_editFilter',
            modal: true,
            height: 500,
            width: 600,
            resizable: false,
            autoScroll: true,
            layout: 'fit',
            items: [
                Ext.create('widget.formcreatefilter', {
                    filter: this.record
                })
            ]
        }).show();
    }
});
